<?php

namespace pmvc\remoting;

use pmvc\ioc\FactoryObject;
use pmvc\aop\ProxyUtil;
use Exception;

/**
 * An abstract {@link FactoryObject} for remoting that
 * uses a service interface and MethodInterceptor to
 * create remoting objects.
 */
abstract class RemotingClientFactoryObject
	implements FactoryObject {

	private $serviceInterface;
	private $serviceProxy;

	/**
	 * {@inheritDoc}
	 */
	public function createObject() {
		return ProxyUtil::dynamicProxy(
			$this->createMethodInterceptor(),
			NULL, $this->serviceInterface);
	}

	/**
	 * Creates the {@link MethodInterceptor} that will
	 * handle invocation of the service methods.
	 * @return MethodInterceptor the MethodInterceptor
	 */
	protected abstract function createMethodInterceptor();

	/**
	 * Sets the service interface.
	 * @param string $serviceInterface
	 */
	public function setServiceInterface($serviceInterface) {
		$this->serviceInterface = $serviceInterface;
	}

	/**
	 * Returns the service interface.
	 * @return the service interface
	 */
	protected function getServiceInterface() {
		return $this->serviceInterface;
	}
	
}

?>